package com.heba.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.heba.greenmulu.R;


/**
 * 提示对话框
 * <p>
 * Created by shenghao on 6/16/15.
 */
public class ErrorDialog {

    /**
     * 确认对话框
     *
     * @param context
     * @param title
     * @param message
     * @return
     */
    public static AlertDialog Show(Context context, String title, String message) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                context);

        // set title
        alertDialogBuilder.setTitle(title);

        // set dialog message
        alertDialogBuilder
                .setMessage(message)
                .setPositiveButton(R.string.ok, null)
                .setCancelable(false);

        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();
        return alertDialog;
    }

    /**
     * 监听确定按钮事件的确认对话框
     *
     * @param context
     * @param title
     * @param message
     * @param onClickListener
     * @return
     */
    public static AlertDialog showWithConfirmClick(Context context, String title, String message, DialogInterface.OnClickListener onClickListener) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                context);

        // set title
        alertDialogBuilder.setTitle(title);

        // set dialog message
        alertDialogBuilder
                .setMessage(message)
                .setPositiveButton(R.string.ok, onClickListener)
                .setCancelable(false);

        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();
        return alertDialog;
    }

    /**
     * @param context
     * @param title
     * @param message
     * @param ok
     * @param onClickListener
     * @return
     */
    public static AlertDialog showWithConfirmClick(Context context, String title, String message, String ok, DialogInterface.OnClickListener onClickListener) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                context);

        // set title
        alertDialogBuilder.setTitle(title);

        // set dialog message
        alertDialogBuilder
                .setMessage(message)
                .setPositiveButton(ok, onClickListener)
                .setCancelable(false);

        // create alert dialog
        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();
        return alertDialog;
    }
}
